package com.wjzjq.hiring.common;

import java.util.List;

/**
 * 分页模型 <br>
 * 2016年9月19日
 * 
 * @author gzy 无极之岚
 * @param <T>
 */
public class PageModel<T> {

	/**
	 * 数据集
	 */
	private List<T> list;
	/**
	 * 总条数
	 */
	private int totalRecords;
	/**
	 * 当前页数
	 */
	private int pageNum;
	/**
	 * 当前页面总数据数
	 */
	private int pageSum;

	public PageModel(List<T> list, int totalRecords, int pageNum, int pageSum) {
		super();
		this.list = list;
		this.totalRecords = totalRecords;
		this.pageNum = pageNum;
		this.pageSum = pageSum;
	}

	/**
	 * 获取总页数
	 * 
	 * @return
	 */
	public int getTotalPages() {
		return (int) Math.ceil((double) totalRecords / pageSum);
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSum() {
		return pageSum;
	}

	public void setPageSum(int pageSum) {
		this.pageSum = pageSum;
	}

	public List<T> getList() {
		return list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}
}
